home *** CD-ROM | disk | FTP | other *** search
- /*
- File: ShimSerialStub.c
-
- Contains: Routines used to insterface to the shim
-
- Version: xxx put version here xxx
-
- Written by:
-
- Copyright: © 1996-1998 by Apple Computer, Inc., all rights reserved.
-
-
- */
-
- #include <Errors.h>
- #include <LowMem.h>
- #include <TextUtils.h>
-
- #include "Modem.h"
- #include "ShimSerialStub.h"
-
- //
- // Statically define the Icon & Icon Mask for
- // the CRM structures. In the new world
- // (this was Rhapsody) we don't have resources
- // so we have to do it the hard way.
- // This doesn't make sense anymore we should
- // change this to support resource based icons
- //
-
- UInt32 CRMDeviceIcon[] = {
- 0xFFFFFFFF, 0x80000001, 0x80018001, 0x80018001,
- 0x80024001, 0x80042001, 0x80042001, 0x80081001,
- 0x800E7001, 0x80024FC1, 0x80C24841, 0x81224841,
- 0x82124841, 0x82124CC1, 0x82124501, 0x81224901,
- 0x80A25201, 0x80926401, 0x804A0801, 0x80261001,
- 0x80102001, 0x80084001, 0x80044001, 0x80024001,
- 0x80042001, 0x80081001, 0x80081001, 0x80081001,
- 0x80042001, 0x8003C001, 0x80000001, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF
- };
-
- /***********************************************************************************/
- // Function: InstallShimDrvr(CFragConnectionID ConnID)
- // Description: Handles the interface with the shim install
- //
- // Input: CFrag Connection ID (mine)
- // Output: Results
- /***********************************************************************************/
-
- OSErr InstallShimDrvr(CFragConnectionID ConnID)
- {
- OSErr err;
- SerialShimInterface IntBlk;
-
- TraceMessage(0, "\pEntering InstallShimDrvr");
-
- err = LoadShim();
- if (err == noErr)
- {
- IntBlk.DRVRInName = kDRVRInName;
- IntBlk.DRVROutName = kDRVROutName;
- IntBlk.CRMName = kCRMName;
- IntBlk.CRMIcon = (IconPtr)&CRMDeviceIcon;
- IntBlk.MaxSpeed = kMaxBaudRate;
- IntBlk.RefCon = 0;
- IntBlk.ConnID = ConnID;
- err = (*gGlobals->ShimInstall) (IntBlk, &gGlobals->ShimRef);
- }
-
- return err;
- }
-
- /***********************************************************************************/
- // Function: RemoveShimDrvr(Boolean forceFlag)
- // Description: Handles the interface with the shim remove
- //
- // Input: Orderly or forced
- // Output: Results
- /***********************************************************************************/
-
- OSErr RemoveShimDrvr(Boolean forceFlag)
- {
- OSErr err;
-
- TraceMessage(0, "\pEntering RemoveShimDrvr");
-
- if (gGlobals->ShimRef != kInvalidRef)
- {
- err = (*gGlobals->ShimRemove) (gGlobals->ShimRef, forceFlag);
- // if (err == noErr)
- // UnLoadShim();
- }
-
- return err;
- }
-
- /***********************************************************************************/
- // Function: LoadShim
- // Description: Loads the shim and sets up the various addresses
- //
- // Input: Nothing
- // Output: Results
- /***********************************************************************************/
-
- OSErr LoadShim(void)
- {
- OSErr err = noErr; // Let's assume success
- Ptr FragAddr;
- CFragConnectionID ConnID;
- Str255 errMsg;
- CFragSymbolClass cClass;
-
- err = GetSharedLibrary("\pSerialShimLib", kPowerPCCFragArch, kLoadCFrag, &ConnID, &FragAddr, errMsg);
- if (err == noErr)
- {
- gGlobals->ConnID = ConnID;
- err = FindSymbol(ConnID, "\pSerialShimInstallDriver", (Ptr *)&gGlobals->ShimInstall, &cClass);
- if ((err != noErr) || (cClass != kTVectorCFragSymbol))
- {
- err = -1;
- }
-
- if (err == noErr)
- {
- err = FindSymbol(ConnID, "\pSerialShimRemoveDriver", (Ptr *)&gGlobals->ShimRemove, &cClass);
- if ((err != noErr) || (cClass != kTVectorCFragSymbol))
- {
- err = -1;
- }
- }
-
- if (err == noErr)
- {
- err = FindSymbol(ConnID, "\pSerialShimIOComplete", (Ptr *)&gGlobals->ShimComplete, &cClass);
- if ((err != noErr) || (cClass != kTVectorCFragSymbol))
- {
- err = -1;
- }
- }
- }
-
- return err;
- }
-
- /***********************************************************************************/
- // Function: UnLoadShim
- // Description: UnLoads the shim, actually closes the connection
- //
- // Input: Nothing
- // Output: Results
- /***********************************************************************************/
-
- OSErr UnLoadShim(void)
- {
- OSErr err = noErr; // Let's assume success
-
- err = CloseConnection(&gGlobals->ConnID);
-
- return err;
-
- }
-
- /***********************************************************************************/
- // Function: ShimIOComplete
- // Description: Sets up and calls the shim's completion routine
- //
- // Input: Parameter block and result code
- // Output: nothing
- /***********************************************************************************/
-
- void ShimIOComplete(ParmBlkPtr pb, OSErr result)
- {
- pb->ioParam.ioResult = result;
- (*gGlobals->ShimComplete) (gGlobals->ShimRef, (IOParam *)pb);
-
- }